home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: sfluhrer@ix.netcom.com(Scott Fluhrer)
- Newsgroups: comp.lang.c
- Subject: Re: How to get a random strin
- Date: 27 Feb 1996 04:34:53 GMT
- Organization: Netcom
- Message-ID: <4gu1ld$nis@ixnews3.ix.netcom.com>
- References: <4g19id$p7n@gail.ripco.com> <Dn5E0J.GKL@thinkage.on.ca> <4gqir9$d5r@airdmhor.gen.nz>
- NNTP-Posting-Host: ix-clv2-22.ix.netcom.com
- X-NETCOM-Date: Mon Feb 26 8:34:54 PM PST 1996
-
- In <4gqir9$d5r@airdmhor.gen.nz> gumboot@airdmhor.gen.nz (Simon Hosie)
- writes:
- [Perfectly correct advise about time() returning a time_t, which might
- be a float, and so you have to #include <time.h> to tell the compiler
- that]
- >
- > I don't follow that.. if time returns a float then won't the result
- >be cast and truncated to an int?
- Well, if the compiler doesn't know that time returns a float, then it
- won't know to insert the code to do the cast. So, you may get the bit
- pattern of the float, interpretted as an int, or, as the previous
- poster stated, you might get an integer register which happends to be
- always the same value when time() returns.
- >
- >Is the following legal, by the way?
- >
- > char Temp[sizeof(time_t) + sizeof(unsigned)];
- >
- > time((time_t *)Temp);
- > srand(*(unsigned *)Temp);
- Absolutely not: for one, the Temp array needn't be alignmented properly
- to hold either a time_t or an unsigned int.
-
- poncho
-